package com.qding.park.adapter.report.valid;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.apache.commons.lang3.StringUtils;


public class PayModeValid implements ConstraintValidator<PayMode, String> {

	private PayMode constraintAnnotation;
	
	/**
	 * @Field @onLine : TODO(线上)
	 */
	private final static String onLine="on-line";
	
	/**
	 * @Field @line : TODO(线下)
	 */
	private final static String line="line";
	
	/**
	 * @Field @machineLine : TODO(线下缴费机)
	 */
	private final static String machineLine="machine-line";
    @Override
    public void initialize(PayMode constraintAnnotation) {
        this.constraintAnnotation = constraintAnnotation;
        
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(StringUtils.isBlank(value)){
            return false;
        }
        
        if(onLine.equals(value)){
            return true;
        }else if(line.equals(value)){
            return true;
        }else if(machineLine.equals(value)){
            return true;
        }
        
        return false;
    }


//
//	@Override
//	public boolean isValid(Integer value, ConstraintValidatorContext context) {
//		
//		if(value==null){
//			//为空就不验证了
//			return true;
//		}
//		String arrayStr=constraintAnnotation.intArray();
//		
//		if(StringUtil.isBlank(arrayStr)){
//		    return false;
//		}
//
//		try {
//		   String [] intStrs= arrayStr.split(",");
//		   List<String> userList = new ArrayList<String>();
//		   Collections.addAll(userList, intStrs);
//		   if(!userList.contains(String.valueOf(value))){
//		       return false;
//		   }
//		} catch (Exception e) {
//			System.out.println("intArray　格式不对");
//			return false;
//		}
//		return true;
//	}

}
